import request from '@/utils/request'

// 获取积分历史列表
export function getPointsHistoryList(query) {
  return request({
    url: '/api/v1/points/history',
    method: 'get',
    params: query
  })
}

// 获取用户积分信息
export function getUserPoints(userId) {
  return request({
    url: `/api/v1/points/user/${userId}`,
    method: 'get'
  })
}

// 获取当前用户积分信息
export function getCurrentUserPoints() {
  return request({
    url: '/api/v1/points/user',
    method: 'get'
  })
}

// 增加用户积分
export function addUserPoints(data) {
  return request({
    url: '/api/v1/points/add',
    method: 'post',
    data
  })
}

// 扣减用户积分
export function deductUserPoints(data) {
  return request({
    url: '/api/v1/points/deduct',
    method: 'post',
    data
  })
}

// 获取积分统计信息
export function getPointsStatistics(query) {
  return request({
    url: '/api/v1/points/statistics',
    method: 'get',
    params: query
  })
}

// 获取积分配置
export function getPointsConfig() {
  return request({
    url: '/api/v1/points/config',
    method: 'get'
  })
}

// 更新积分配置
export function updatePointsConfig(data) {
  return request({
    url: '/api/v1/points/config',
    method: 'put',
    data
  })
}

// 获取可兑换商品列表
export function getExchangeGoods(query) {
  return request({
    url: '/api/v1/points/exchange/goods',
    method: 'get',
    params: query
  })
}

// 兑换商品
export function exchangeGoods(data) {
  return request({
    url: '/api/v1/points/exchange',
    method: 'post',
    data
  })
}
